﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

public partial class about : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.menu.Logo = "1";
            InitLeftNav();
            if (null != Request.QueryString["id"])
            {
                InitContent(Convert.ToInt32(Request.QueryString["id"].ToString()));
            }
        }
    }

    private void InitLeftNav()
    {
        CItem item = new CItem();
        DataTable dt = item.ReadItems(1);
        StringBuilder sb = new StringBuilder();
        if (null != dt)
        {
            if (null == Request.QueryString["id"])
            {
                InitContent(Convert.ToInt32(dt.Rows[0]["id"].ToString()));
            }
            foreach (DataRow r in dt.Rows)
            {
                sb.Append("<a href=\"about.aspx?id=" + r["id"].ToString() + "\">" + r["title"].ToString() + "</a>");
            }
        }
        this.ltlLeftNav.Text = sb.ToString();
    }

    private void InitContent(int id)
    {
        CItem item = new CItem();
        DataRow r = item.ReadItem(id);
        if (null != r)
        {
            this.ltlTopNav.Text = r["title"].ToString();
            this.ltlContent.Text = r["content"].ToString();
        }
    }
}